function myNew(fun,...arg){
    if(typeof fun !== 'function'){
        throw new TypeError('fun is not a function')
    }
    if(!fun.prototype){
        throw new TypeError('fun is not a constructor')
    }
    let newObj = Object.create(null)
    newObj.__proto__=fun.prototype
    newObj.constructor = fun//很多人都会忽视的一步
    let res = fun.call(newObj,arg)
   
    return ((typeof res) === 'object' && res!==null) ? res : newObj
}
let c =function() {
    return null
}
let x = myNew(c)
console.log(x.__proto__===c.prototype);
console.log(x.constructor===c);